import java.net.InetAddress;

public class Main {
    public static void main(String[] args) {
        try {
            //获取本机的ip地址
            InetAddress ip1 = InetAddress.getLocalHost();
            System.out.println(ip1.getHostName());
            System.out.println(ip1.getHostAddress());

            //获取别的机器的ip地址
            InetAddress ip2 = InetAddress.getByName("www.baidu.com");
            System.out.println(ip2.getHostName());
            System.out.println(ip2.getHostAddress());

            //判断当前机器与目标机器是否在指定时间内产生通信
            System.out.println(ip2.isReachable(6000));
        }catch (Exception e){

        }
    }
}